/**
 * This file is Copyright © 2008 Software Craftsmen Limited. All Rights Reserved.
 */
package com.softwarecraftsmen.cachecontrol;

import com.softwarecraftsmen.cachecontrol.keys.AbstractKey;
import com.softwarecraftsmen.cachecontrol.keys.Key;
import org.jetbrains.annotations.NotNull;

public class Value<V>
{
	private final Cache<V> cache;
	private final V value;

	public Value(@NotNull final Cache<V> cache, @NotNull final V value)
	{
		this.cache = cache;
		this.value = value;
	}

	public @NotNull Item<V> at(@NotNull final Key<V> key)
	{
		return cache.store(key, value);
	}

	public @NotNull Item<V> at(@NotNull final Object ... orderedKeyComponents)
	{
		Key<V> key = AbstractKey.createKey(orderedKeyComponents);
		return at(key);
	}
}
